package com.zjitc.book.mapper;

import com.zjitc.book.entity.Book;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BookMapper {

    @Select("select * from book_db.t_book")
    public List<Book> getBooks();

    @Select("select * from book_db.t_book where id = #{id}")
    public Book getBooksById(@Param("id") Integer id);

    @Delete("delete from book_db.t_book where id = #{id}")
    int deleteBookById(@Param("id") Integer id);

    @Update("update book_db.t_book set name = #{name}, type = #{type} where id = #{id}")
    int updateBookById(@Param("id") Integer id, @Param("book") Book book);

    @Insert("insert into book_db.t_book(id,name,type) values (NULL,#{name},#{type})")
    int insertBook(Book book);

    public List<Book> searchBooksByCondition(Book book);
}
